package com.example.tests;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.logging.Logger;
import org.testng.annotations.Test;

import com.example.fw.GroupObject;
import com.example.fw.Groups;

public class GroupCreationTests extends TestBase {
	
	private  Logger log = Logger.getLogger("GroupCreationTests");
	
	@Test(dataProvider = "groupsFromFile", dataProviderClass = GroupDataGenerator.class)
	public void testValidGroupCanBeCreated(GroupObject validGroup) throws Exception {
		log.info("testValidGroupCanBeCreated start");
		Groups oldList = app.getGroupHelper().getGroups();
		log.info("oldList = " + oldList);
		// action
		log.info("validGroup = " + validGroup);
		app.getGroupHelper().createGroup(validGroup);
		// verification
		Groups newList = app.getGroupHelper().getGroups();
		log.info("newList = " + newList);
		assertThat(newList, equalTo(oldList.withAdded(validGroup)));
		log.info("testValidGroupCanBeCreated end");
	}

	//@Test
	public void testEmptyGroupCanBeCreated() throws Exception {
		GroupObject emptyData = new GroupObject()
		    .setName("").setHeader("").setFooter("");
		Groups oldList = app.getGroupHelper().getGroups();
		app.getGroupHelper().createGroup(emptyData);
		Groups newList = app.getGroupHelper().getGroups();
		assertThat(newList, equalTo(oldList.withAdded(emptyData)));
	}
}